#ifdef _WIN32
#ifndef __SERIAL_H__
#define __SERIAL_H__

#define FC_DTRDSR 0x01
#define FC_RTSCTS 0x02
#define FC_XONXOFF 0x04
#define ASCII_BEL 0x07
#define ASCII_BS 0x08
#define ASCII_LF 0x0A
#define ASCII_CR 0x0D
#define ASCII_XON 0x11
#define ASCII_XOFF 0x13

#include <Windows.h> // 包含Windows.h头文件
#include <string>

class serialPort
{

public:
	serialPort();
	~serialPort();

	BOOL Open(int nPort = 2, int nBaud = 9600);
	BOOL Close(void);

	int ReadData(void *, int);
	int SendData(const char *, int);
	int ReadDataWaiting(void);

	BOOL IsOpened(void) { return (m_bOpened); }
	int ReadChar(uint8_t &b);

protected:
	BOOL WriteCommByte(unsigned char);

	HANDLE m_hIDComDev;
	// E_HANDLE m_hIDComDev;
	OVERLAPPED m_OverlappedRead, m_OverlappedWrite;
	BOOL m_bOpened = false;
};
#endif
#endif